<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Module: utils/axios</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Module: utils/axios</h1>

    




<section>

<header>
    
        
            
        
            
        
    
</header>

<article>
    <div class="container-overview">
    
        
            <div class="description"><p>Axios 实例, ajax请求底层方法
 官方文档 <a href="https://github.com/axios/axios">https://github.com/axios/axios</a></p></div>
        

        
            

    

    
    <h4 class="name" id="module:utils/axios"><span class="type-signature"></span>module:utils/axios<span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Axios 实例</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="axios.js.html">axios.js</a>, <a href="axios.js.html#line226">line 226</a>
    </li></ul></dd>
    

    

    

    
</dl>

















    <h5>Examples</h5>
    
    <pre class="prettyprint"><code>// 基础用法
 import axios from '@/utils/axios'
 axios({
   method: 'post',
   url: '/user/123',
   data: {
     firstName: 'Fred',
     lastName: 'Flintstone'
   }
 })

 </code></pre>

    <pre class="prettyprint"><code>// 实例方法
 axios.request(config)
 axios.get(url[, config])
 axios.delete(url[, config])
 axios.head(url[, config])
 axios.options(url[, config])
 axios.post(url[, data[, config]])
 axios.put(url[, data[, config]])
 axios.patch(url[, data[, config]])</code></pre>

    <pre class="prettyprint"><code>config
{
  // `url` is the server URL that will be used for the request
  url: '/user',

  // `method` is the request method to be used when making the request
  method: 'get', // default

  // `baseURL` will be prepended to `url` unless `url` is absolute.
  // It can be convenient to set `baseURL` for an instance of axios to pass relative URLs
  // to methods of that instance.
  baseURL: 'https://some-domain.com/api/',
  // `transformRequest` allows changes to the request data before it is sent to the server
  // This is only applicable for request methods 'PUT', 'POST', and 'PATCH'
  // The last function in the array must return a string or an instance of Buffer, ArrayBuffer,
  // FormData or Stream
  // You may modify the headers object.
  transformRequest: [function (data, headers) {
    // Do whatever you want to transform the data

    return data;
  }],

  // `transformResponse` allows changes to the response data to be made before
  // it is passed to then/catch
  transformResponse: [function (data) {
    // Do whatever you want to transform the data

    return data;
  }],

 // `headers` are custom headers to be sent
  headers: {'X-Requested-With': 'XMLHttpRequest'},

  // `params` are the URL parameters to be sent with the request
  // Must be a plain object or a URLSearchParams object
  params: {
    ID: 12345
  },

  // `paramsSerializer` is an optional function in charge of serializing `params`
  // (e.g. https://www.npmjs.com/package/qs, http://api.jquery.com/jquery.param/)
  paramsSerializer: function(params) {
    return Qs.stringify(params, {arrayFormat: 'brackets'})
  },

  // `data` is the data to be sent as the request body
  // Only applicable for request methods 'PUT', 'POST', and 'PATCH'
  // When no `transformRequest` is set, must be of one of the following types:
  // - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams
  // - Browser only: FormData, File, Blob
  // - Node only: Stream, Buffer
  data: {
    firstName: 'Fred'
  },

  // `timeout` specifies the number of milliseconds before the request times out.
  // If the request takes longer than `timeout`, the request will be aborted.
  timeout: 1000,

  // `withCredentials` indicates whether or not cross-site Access-Control requests
  // should be made using credentials
  withCredentials: false, // default

  // `adapter` allows custom handling of requests which makes testing easier.
  // Return a promise and supply a valid response (see lib/adapters/README.md).
  adapter: function (config) {

  },

  // `auth` indicates that HTTP Basic auth should be used, and supplies credentials.
  // This will set an `Authorization` header, overwriting any existing
  // `Authorization` custom headers you have set using `headers`.
  auth: {
    username: 'janedoe',
    password: 's00pers3cret'
  },

  // `responseType` indicates the type of data that the server will respond with
  // options are 'arraybuffer', 'blob', 'document', 'json', 'text', 'stream'
  responseType: 'json', // default

  // `responseEncoding` indicates encoding to use for decoding responses
  // Note: Ignored for `responseType` of 'stream' or client-side requests
  responseEncoding: 'utf8', // default

  // `xsrfCookieName` is the name of the cookie to use as a value for xsrf token
 xsrfCookieName: 'XSRF-TOKEN', // default

  // `xsrfHeaderName` is the name of the http header that carries the xsrf token value
  xsrfHeaderName: 'X-XSRF-TOKEN', // default

  // `onUploadProgress` allows handling of progress events for uploads
  onUploadProgress: function (progressEvent) {
    // Do whatever you want with the native progress event
  },

  // `onDownloadProgress` allows handling of progress events for downloads
  onDownloadProgress: function (progressEvent) {
    // Do whatever you want with the native progress event
  },

  // `maxContentLength` defines the max size of the http response content in bytes allowed
  maxContentLength: 2000,

  // `validateStatus` defines whether to resolve or reject the promise for a given
  // HTTP response status code. If `validateStatus` returns `true` (or is set to `null`
  // or `undefined`), the promise will be resolved; otherwise, the promise will be
  // rejected.
  validateStatus: function (status) {
    return status >= 200 &amp;&amp; status &lt; 300; // default
  },

  // `maxRedirects` defines the maximum number of redirects to follow in node.js.
  // If set to 0, no redirects will be followed.
  maxRedirects: 5, // default

  // `socketPath` defines a UNIX Socket to be used in node.js.
  // e.g. '/var/run/docker.sock' to send requests to the docker daemon.
  // Only either `socketPath` or `proxy` can be specified.
  // If both are specified, `socketPath` is used.
  socketPath: null, // default

  // `httpAgent` and `httpsAgent` define a custom agent to be used when performing http
  // and https requests, respectively, in node.js. This allows options to be added like
  // `keepAlive` that are not enabled by default.
  httpAgent: new http.Agent({ keepAlive: true }),
  httpsAgent: new https.Agent({ keepAlive: true }),

  // 'proxy' defines the hostname and port of the proxy server
  // Use `false` to disable proxies, ignoring environment variables.
  // `auth` indicates that HTTP Basic auth should be used to connect to the proxy, and
  // supplies credentials.
  // This will set an `Proxy-Authorization` header, overwriting any existing
  // `Proxy-Authorization` custom headers you have set using `headers`.
  proxy: {
    host: '127.0.0.1',
    port: 9000,
    auth: {
      username: 'mikeymike',
      password: 'rapunz3l'
   }
  },

  // `cancelToken` specifies a cancel token that can be used to cancel the request
  // (see Cancellation section below for details)
  cancelToken: new CancelToken(function (cancel) {
  })
}</code></pre>



        
            















<dl class="details">

    

    

    

    

    

    

    

    

    
    <dt class="tag-author">Author:</dt>
    <dd class="tag-author">
        <ul>
            <li>陈华春</li>
        </ul>
    </dd>
    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="axios.js.html">axios.js</a>, <a href="axios.js.html#line1">line 1</a>
    </li></ul></dd>
    

    

    

    
</dl>


















        
    
    </div>

    

    

    

    

    

    

    
        <h3 class="subsection-title">Members</h3>

        
            
<h4 class="name" id=".source"><span class="type-signature">(static, constant) </span>source<span class="type-signature"> :CancelTokenSource</span></h4>




<div class="description">
    <p>取消请求</p>
</div>



    <h5>Type:</h5>
    <ul>
        <li>
            
<span class="param-type">CancelTokenSource</span>


        </li>
    </ul>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="axios.js.html">axios.js</a>, <a href="axios.js.html#line19">line 19</a>
    </li></ul></dd>
    

    

    

    
</dl>





    <h5>Example</h5>
    
    <pre class="prettyprint"><code>import {source} from '@/utils/axios'
source.cancel('描述文字....')</code></pre>



        
            
<h4 class="name" id="~config"><span class="type-signature">(inner, constant) </span>config<span class="type-signature"> :object</span></h4>




<div class="description">
    <p>Axios实例化参数选项对象</p>
</div>



    <h5>Type:</h5>
    <ul>
        <li>
            
<span class="param-type">object</span>


        </li>
    </ul>





    <h5 class="subsection-title">Properties:</h5>

    

<table class="props">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>headers</code></td>
            

            <td class="type">
            
                
<span class="param-type">object</span>


            
            </td>

            

            

            <td class="description last"><p>请求头对象对象，默认：null</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>timeout</code></td>
            

            <td class="type">
            
                
<span class="param-type">number</span>


            
            </td>

            

            

            <td class="description last"><p>超时时间，默认：0， 不限制</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>withCredentials</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>

            

            

            <td class="description last"><p>是否带上验证信息， 默认：true</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>maxContentLength</code></td>
            

            <td class="type">
            
                
<span class="param-type">number</span>


            
            </td>

            

            

            <td class="description last"><p>限制最大发送内容长度，默认：-1 不限制</p></td>
        </tr>

    
    </tbody>
</table>




<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="axios.js.html">axios.js</a>, <a href="axios.js.html#line30">line 30</a>
    </li></ul></dd>
    

    

    

    
</dl>






        
    

    

    

    
</article>

</section>




</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-utils_ajax.html">utils/ajax</a></li><li><a href="module-utils_axios.html">utils/axios</a></li><li><a href="module-utils_bom.html">utils/bom</a></li><li><a href="module-utils_bus.html">utils/bus</a></li><li><a href="module-utils_console.html">utils/console</a></li><li><a href="module-utils_convert.html">utils/convert</a></li><li><a href="module-utils_cookie.html">utils/cookie</a></li><li><a href="module-utils_crypto.html">utils/crypto</a></li><li><a href="module-utils_date.html">utils/date</a></li><li><a href="module-utils_directives_clipboard.html">utils/directives/clipboard</a></li><li><a href="module-utils_directives_draggable.html">utils/directives/draggable</a></li><li><a href="module-utils_directives_droppable.html">utils/directives/droppable</a></li><li><a href="module-utils_directives_highlight.html">utils/directives/highlight</a></li><li><a href="module-utils_directives_resizable.html">utils/directives/resizable</a></li><li><a href="module-utils_directives_selecttext.html">utils/directives/selecttext</a></li><li><a href="module-utils_dom.html">utils/dom</a></li><li><a href="module-utils_download.html">utils/download</a></li><li><a href="module-utils_events.html">utils/events</a></li><li><a href="module-utils_excel.html">utils/excel</a></li><li><a href="module-utils_hoc.html">utils/hoc</a></li><li><a href="module-utils_lunar.html">utils/lunar</a></li><li><a href="module-utils_messager.html">utils/messager</a></li><li><a href="module-utils_mock.html">utils/mock</a></li><li><a href="module-utils_openlayer.html">utils/openlayer</a></li><li><a href="module-utils_queue.html">utils/queue</a></li><li><a href="module-utils_skin.html">utils/skin</a></li><li><a href="module-utils_socket.html">utils/socket</a></li><li><a href="module-utils_storage.html">utils/storage</a></li><li><a href="module-utils_theme.html">utils/theme</a></li><li><a href="module-utils_tween.html">utils/tween</a></li><li><a href="module-utils_url.html">utils/url</a></li><li><a href="module-utils_util.html">utils/util</a></li></ul><h3>Classes</h3><ul><li><a href="module-utils_directives_draggable-Draggable.html">Draggable</a></li><li><a href="module-utils_directives_droppable-Droppable.html">Droppable</a></li><li><a href="module-utils_directives_resizable-Resizable.html">Resizable</a></li><li><a href="module-utils_events-Events.html">Events</a></li><li><a href="module-utils_messager.html">utils/messager</a></li><li><a href="module-utils_openlayer-Openlayers.html">Openlayers</a></li><li><a href="module-utils_queue-Queue.html">Queue</a></li><li><a href="module-utils_socket.html">utils/socket</a></li><li><a href="ol.source.TileSuperMapRest.html">TileSuperMapRest</a></li></ul><h3>Events</h3><ul><li><a href="module-utils_socket.html#~event:close">close</a></li><li><a href="module-utils_socket.html#~event:error">error</a></li><li><a href="module-utils_socket.html#~event:message">message</a></li><li><a href="module-utils_socket.html#~event:open">open</a></li><li><a href="module-utils_queue-Queue.html#event:complete">complete</a></li><li><a href="module-utils_queue-Queue.html#event:error">error</a></li><li><a href="module-utils_queue-Queue.html#event:success">success</a></li></ul>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Mar 15 2019 14:41:51 GMT+0800 (China Standard Time)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>